<script type="text/javascript">
           function arrayAct(){
                      this.value = null;
                      this.left = null;
                      this.right = null;
                  }
          arrayAct.prototype.add = function(data){
              if (!data) {
                  return;
              };
           if (this.value == null) {
                  this.value = data;
                  return;
              };
               var code = new arrayAct();
              code.value = data;
              if (this.value >= data) {
                  if (this.left == null) {
                      this.left = code;
                  }else{
                      this.left.add(data);
                  }
              }else{
                  if (this.right == null) {
                      this.right = code;
                  }else{
                      this.right.add(data);
                  }
              }
          }
          arrayAct.prototype.print = function(data){
              if (this.left) {
                  console.log(this)
                  this.left.print(data);
              };
              data.push(this.value);
              if (this.right) {
                  console.log(this)
                  this.right.print(data);
              };
          }
              function app(){
                      var array = [2,6,56,102,5,4,47,7000,200,45,24,85,63,954,6222,5],
                      re = [];
                      sortArray = new arrayAct();
                      for (var i = 0; i < array.length; i++) {
                          sortArray.add(array[i]);
                      };
                      console.log(sortArray)
                      sortArray.print(re);
                      console.log(re)
            }
          app();
        </script>
